package com.qianduo.struts.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.qianduo.service.impl.QianduoProductServiceImpl;
import com.qianduo.struts.AbstractAction;
import com.qianduo.util.Constants;
import com.qianduo.vo.QianduoProductForm;

import common.page.PageList;
import common.page.Pagination;

public class QianduoProductAction extends AbstractAction {
	public ActionForward addProduct(ActionMapping mapping,ActionForm form,HttpServletRequest req,HttpServletResponse res){
		//QianduoProductForm qianduoProductForm	= (QianduoProductForm)form;
		return mapping.findForward("addProduct");
	}
	
	public ActionForward listProduct(ActionMapping mapping,ActionForm form,HttpServletRequest req,HttpServletResponse res){
		try{
			//QianduoProductForm qianduoProductForm	= (QianduoProductForm)form;
			QianduoProductServiceImpl service	= (QianduoProductServiceImpl)getBean("qianduoProductService");
			PageList pageList	= Pagination.getPageList(req);
			List<QianduoProductForm> list	= service.listProduct(null, null, null, null, null, null, null, null, null, pageList);
			
			req.setAttribute("list", list);
		}catch(Exception e){
			Constants.log.error(className+" listProduct",e);
		}
		return mapping.findForward("listProduct");
	}
	
	public ActionForward saveOrUpdateProduct(ActionMapping mapping,ActionForm form,HttpServletRequest req,HttpServletResponse res){
		QianduoProductForm qianduoProductForm	= (QianduoProductForm)form;
		
		return listProduct(mapping,form,req,res);
	}
}
